#include <stdio.h>
#include <stdlib.h>

int input[1000001];

void f(int *list, int leftIndex, int rightIndex)
{
    int pivot, temp, l, r, n;

    if (leftIndex >= rightIndex)
    {
        return;
    }

    pivot = rand() % (rightIndex - leftIndex + 1) + leftIndex;
    temp = list[leftIndex];
    list[leftIndex] = list[pivot];
    list[pivot] = temp;
    l = leftIndex;
    r = rightIndex;
    n = list[leftIndex];
    
    while (l < r)
    {
        while (l < r && list[r] >= n)
        {
            r--;
        }
        list[l] = list[r];
        
        while (l < r && list[l] <= n)
        {
            l++;
        }
        list[r] = list[l];
    }
    list[l] = n;

    while (list[l] == n)
    {
        l--;
    }
    while (list[r] == n)
    {
        r++;
    }
    
    f(list, leftIndex, l);
    f(list, r, rightIndex);
}

int main(int argc, char const *argv[])
{
    int i, n;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &input[i]);
    }
    f(input, 0, n - 1);
    for (i = 0; i < n; i++)
    {
        if (i)
        {
            printf(" %d", input[i]);
        }
        else
        {
            printf("%d", input[i]);
        }
    }
    return 0;
}
